package com.jic.product.controller.manage;

import com.alibaba.fastjson.JSONObject;
import com.jic.common.base.vo.RestResult;
import com.jic.product.entity.ProductMedia;
import com.jic.product.entity.ProductPrice;
import com.jic.product.manage.request.ProductMediaRequest;
import com.jic.product.manage.request.ProductPriceRequest;
import com.jic.product.manage.response.ProductPriceResponse;
import com.jic.product.service.ProductMediaService;
import com.jic.product.service.ProductPriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by WS on 2020/2/7  15: 19
 * 商品图片
 */
@RestController
@RequestMapping("/productMedia")
@Api(value = "商品图片", tags = {"商品图片"})
public class ProductMediaController {

    @Autowired
    ProductMediaService productMediaService;


    /*
     *  商品图片保存
     *
     * */
    @ApiOperation(value = "商品图片保存")
    @ResponseBody
    @PostMapping(value = "/saveProductMedia")
    public RestResult saveProductMedia(@RequestBody ProductMediaRequest productMediaRequest) {
        return productMediaService.saveProductMedia(productMediaRequest);
    }

    /*
     *  查询商品图片
     *
     * */
    @ApiOperation(value = "商品图片保存")
    @ResponseBody
    @GetMapping(value = "/queryProductMedia")
    public RestResult<List<ProductMedia>> queryProductMedia(Long productId) {
        ProductMedia productMedia=new ProductMedia();
        productMedia.setProductId(productId);
        return RestResult.success(productMediaService.query(productMedia));
    }
    /*
     *  查询氛围图片
     *
     * */
    @ApiOperation(value = "查询氛围图片")
    @ResponseBody
    @GetMapping(value = "/queryFW")
    public RestResult<List<JSONObject>> queryFW(Long productId) {
        return RestResult.success(productMediaService.queryFW(productId));
    }
}
